﻿namespace UnityEditor
{
    using System;
    using System.Runtime.CompilerServices;
    using UnityEngine;

    public sealed class VCAsset
    {
        private string m_guid;
        private IntPtr m_thisDummy;

        public VCAsset(string clientPath)
        {
            this.InternalCreateFromString(clientPath);
        }

        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern void Dispose();
        public void Edit()
        {
            UnityEngine.Object target = this.Load();
            if (target != null)
            {
                AssetDatabase.OpenAsset(target);
            }
        }

        ~VCAsset()
        {
            this.Dispose();
        }

        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        private extern void InternalCreateFromString(string clientPath);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern bool IsChildOf(VCAsset other);
        public bool IsOneOfStates(States[] states)
        {
            foreach (States states2 in states)
            {
                if ((this.state & states2) != States.None)
                {
                    return true;
                }
            }
            return false;
        }

        public bool IsState(States state)
        {
            return ((this.state & state) != States.None);
        }

        public UnityEngine.Object Load()
        {
            if ((this.state != States.DeletedLocal) && !this.isMeta)
            {
                return AssetDatabase.LoadAssetAtPath(this.projectPath, typeof(UnityEngine.Object));
            }
            return null;
        }

        public string action { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public string assetsPath { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public string fullName { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public string headAction { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public bool isFolder { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public bool isInCurrentProject { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public bool isMeta { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public bool locked { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public string name { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public string path { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public string prettyPath
        {
            get
            {
                string assetsPath = this.assetsPath;
                return (!string.IsNullOrEmpty(assetsPath) ? assetsPath : this.path);
            }
        }

        public string projectPath { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public bool readOnly { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public States state { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public bool unresolved { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        [Flags]
        public enum States
        {
            AddedLocal = 0x100,
            AddedRemote = 0x200,
            CheckedOutLocal = 0x10,
            CheckedOutRemote = 0x20,
            Conflicted = 0x400,
            DeletedLocal = 0x40,
            DeletedRemote = 0x80,
            Local = 1,
            LockedLocal = 0x800,
            LockedRemote = 0x1000,
            MetaFile = 0x8000,
            Missing = 8,
            None = 0,
            OutOfSync = 4,
            ReadOnly = 0x4000,
            Synced = 2,
            Unresolved = 0x10000,
            Updating = 0x2000
        }
    }
}

